<div class="layui-fluid" id="VIEW-list-table" lay-title="客户列表" lig-title="customer-title">
    <div class="layui-row layui-col-space10">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header" lig-lang="label-searchTitle">筛选数据</div>
                <div class="layui-card-body">
                    <div class="layui-row layui-col-space10 layui-form">
                        <form class="layui-form" lay-filter="lig-customer-searchform" id="lig-searchform">
                            <div class="layui-row">
                                <div class="layui-inline">
                                    <label class="layui-form-label" lig-lang="cu-customerCode">客户编码</label>
                                    <div class="layui-inline">
                                        <input type="text" class="layui-input" name="customerCode"/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label" lig-lang="cu-name">名称</label>
                                    <div class="layui-inline">
                                        <input type="text" class="layui-input" name="name"/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <div class="layui-row layui-col-space10">
                                        <div class="layui-col-xs6">
                                            <div class="layui-btn layui-btn-sm layui-btn-fluid"
                                                 lay-filter="lig-customer-search" lig-lang="btn-search">查询
                                            </div>
                                        </div>
                                        <div class="layui-col-xs6">
                                            <button type="reset" class="layui-btn layui-btn-sm layui-btn-primary" lig-lang="btn-reset">重置</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div class="layui-card">
                <div class="layui-card-body nepadmin-table-full">
                    <div class="layui-btn-container nepadmin-pad-t10 nepadmin-pad-l10">
                        <div class="layui-btn layui-btn-sm" lay-filter="lig-customer-add" lig-lang="btn-addCustomer">添加客户</div>
                    </div>
                    <table lay-filter="lig-customer-table"></table>
                </div>
            </div>
        </div>
    </div>
    <script type="text/html" id="tpl-row-toolBar">
        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="lig-modify" lay-filter="lig-customer-modify" lig-lang="btn-modify">修改</a>
        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="lig-delete" lay-filter="lig-customer-delete" lig-lang="btn-delete">删除</a>
        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="lig-admin" lay-filter="lig-customer-admin" lig-lang="btn-admin">管理员</a>
    </script>
    <script type="text/html" id="tpl-customer-modify">
        <form class="layui-form" lay-filter="lig-saveform" id="lig-saveform" style="padding-top: 20px;">
            <input type="hidden" name="customerId" value="{{d.customerId}}"/>
            <div class="layui-form-item">
                <label class="layui-form-label ligui-form-item-required" lig-lang="cu-customerCode">客户编码</label>
                <div class="layui-input-block">
                    <input type="text" name="customerCode" autocomplete="off" class="layui-input" lay-verify="required"
                           value='{{d.customerCode}}'>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label ligui-form-item-required" lig-lang="cu-nameCn">中文名</label>
                <div class="layui-input-block">
                    <input type="text" name="nameCn" autocomplete="off" class="layui-input" lay-verify="required"
                           value='{{d.nameCn}}'>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label ligui-form-item-required" lig-lang="cu-nameEn">英文名</label>
                <div class="layui-input-block">
                    <input type="text" name="nameEn" autocomplete="off" class="layui-input" lay-verify="required"
                           value='{{d.nameEn}}'>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label ligui-form-item-required" lig-lang="cu-customerType">类别</label>
                <div class="layui-input-block">
                    <select name="customerType" lay-verify="required">
                        <option value="客户" selected="{{d.nameEn=='客户'}}" lig-lang="cu-customer">客户</option>
                        <option value="供应商" selected="{{d.nameEn=='供应商'}}" lig-lang="cu-supplier">供应商</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" lig-lang="cu-address">地址</label>
                <div class="layui-input-block">
                    <input type="text" name="address" autocomplete="off" class="layui-input"
                           value='{{d.address}}'>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" lig-lang="cu-remark">备注</label>
                <div class="layui-input-block">
                    <input type="text" name="remark" autocomplete="off" class="layui-input"
                           value='{{d.remark}}'>
                </div>
            </div>
        </form>
    </script>
    <script type="text/html" id="tpl-customer-add">
        <form class="layui-form" lay-filter="lig-saveform" id="lig-customer-addform" style="padding-top: 20px;">
            <div class="layui-form-item">
                <label class="layui-form-label ligui-form-item-required" lig-lang="cu-customerCode">客户编码</label>
                <div class="layui-input-block">
                    <input type="text" name="customerCode" autocomplete="off" class="layui-input" lay-verify="required"
                           value=''>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label ligui-form-item-required" lig-lang="cu-nameCn">中文名</label>
                <div class="layui-input-block">
                    <input type="text" name="nameCn" autocomplete="off" class="layui-input" lay-verify="required"
                           value=''>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label ligui-form-item-required" lig-lang="cu-nameEn">英文名</label>
                <div class="layui-input-block">
                    <input type="text" name="nameEn" autocomplete="off" class="layui-input" lay-verify="required"
                           value=''>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label ligui-form-item-required" lig-lang="cu-customerType">类别</label>
                <div class="layui-input-block">
                    <select name="customerType" lay-verify="required">
                        <option value="客户" lig-lang="cu-customer">客户</option>
                        <option value="供应商" lig-lang="cu-supplier">供应商</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" lig-lang="cu-address">地址</label>
                <div class="layui-input-block">
                    <input type="text" name="address" autocomplete="off" class="layui-input"
                           value=''>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" lig-lang="cu-remark">备注</label>
                <div class="layui-input-block">
                    <input type="text" name="remark" autocomplete="off" class="layui-input"
                           value=''>
                </div>
            </div>

        </form>
    </script>
</div>
<script>
    var selectedTenantId;
    layui.use(['admin', 'table', 'form', 'dropdown', 'laytpl', 'jquery', 'lig'], function (admin, table, form, dropdown, laytpl, $, lig) {

        form.render();

        lig.table({
            elem: '[lay-filter="lig-customer-table"]',
            url: 'pd/customer/page',
            cols: [[
                {title: '<span lig-lang="label-opt">操作</span>', toolbar: '#tpl-row-toolBar', align: 'left', width: 200, fixed: 'left'},
                {title: '<span lig-lang="cu-customerCode">客户编码</span>', field: 'customerCode', align: 'left', minWidth: 100},
                {title: '<span lig-lang="cu-customerType">类别</span>', field: 'customerType', align: 'left', minWidth: 120},
                {title: '<span lig-lang="cu-nameCn">中文名</span>', field: 'nameCn', align: 'left', minWidth: 100},
                {title: '<span lig-lang="cu-nameEn">英文名</span>', field: 'nameEn', align: 'left', minWidth: 100},
                {title: '<span lig-lang="cu-address">地址</span>', field: 'address', align: 'left', minWidth: 200},
                {title: '<span lig-lang="cu-remark">备注</span>', field: 'remark', align: 'left', minWidth: 120},
                {
                    title: '<span lig-lang="cu-createdTime">创建时间</span>',
                    field: 'createdTime',
                    align: 'left',
                    templet: '<div>{{ layui.util.toDateString(d.createdTime, "yyyy-MM-dd HH:mm:ss") }}</div>',
                    minWidth: 200
                }
            ]]
        }, {
            mode: 'dialog',
            area: ['50%', 'auto'],
            entity: 'customer',
            primaryField: 'customerId',
            addContent: $('#tpl-customer-add').html(),
            addUrl: 'pd/customer/add',
            addTitle: '<span lig-lang="cu-addCustomer">添加客户</span>',
            onAddOpened: function () {
            },
            modifyContent: $('#tpl-customer-modify').html(),
            modifyUrl: 'pd/customer/modify',
            modifyTitle: '<span lig-lang="cu-modifyCustomer">修改客户</span>',
            onModifyOpened: function () {
            },
            removeUrl: 'pd/customer/remove',
            getUrl: 'pd/customer/{customerId}',

            onTool: function (obj) {
                if (obj.event == 'lig-admin') {
                    selectedTenantId = obj.data.tenantId;
                    admin.popup({
                        title: '<span lig-lang="cu-admin">管理员</span>',
                        url: 'pd/customer_user',
                        area:['60%', '60%'],
                        success: function () {
                        }
                    });
                }
            }
        });
    })
</script>